<?php

	$user = $controller->getCurrentUser();                                                                                                                                                                                                                                                                                                                                                                                                                                                      
	//on verifie les permissions
	if ($user->isAllowedTo(GRADE_MOD_BOOK))
	{
		if (!$typeRequest = $request->getParam('type'))
			throw new exceptionErrorManual(0,'champ type attendu en post',__file__,__line__);
		else  
		{
			if (!$element = $request->getParam('element'))
				throw new exceptionErrorManual(0,'champ element attendu en post',__file__,__line__);    
			else if ($element == 'Inconnu' || $element=='Inconnue')
			{
				$controller->addError('Vous ne pouvez modifier cet &eacute;l&eacute;ment');
				$controller->forward('manageAuthorsSeries');
			}
			else
			{
				switch ($typeRequest)	
				{
					case 'author' :
						$author = author::singleton($element, 'name');
						if (!$author->getId())
						{
							$controller->addError('Auteur inconnu');
							$controller->forward('manageAuthorsSeries');
						}
						else
						{
							$controller->setVar('author',$author);
							$controller->render('changeAuthor');						
						}
						break;
					case 'serie' :
						$serie = serie::singleton($element, 'name');                                
						if (!$serie->getId())
						{
							$controller->addError('S&eacute;rie inconnue');
							$controller->forward('manageAuthorsSeries');
						}
						else
						{
							$controller->setVar('serie',$serie);
							$controller->render('changeSerie');
						}
						break;
					case 'publisher' :
						$publisher = publisher::singleton($element, 'name');                                
						if (!$publisher->getId())
						{
							$controller->addError('&Eacute;diteur inconnu');
							$controller->forward('manageAuthorsSeries');
						}
						else
						{
							$controller->setVar('publisher',$publisher);
							$controller->render('changePublisher');                        
						}
						break;
					default :
						throw new exceptionErrorManual(0,'valeurs fermees pour le champ type',__file__,__line__);        
						break;
				}
			}
		}
	}
	else
		$controller->render('errorRights');
	
?>
